﻿using Microsoft.Practices.Composite.Regions;
using Microsoft.Practices.Unity;
using Shatkotha.WPF.Global;
using Shatkotha.WPF.Global.Modules;
using Shatkotha.WPF.Global.Modules.SMS;
using Shatkotha.WPF.SMS.Presenters;
using Shatkotha.WPF.SMS.Views;

namespace Shatkotha.WPF.SMS
{
    public class SmsModule : ISmsModule
    {
        public SmsModule(IRegionManager regionManager, IUnityContainer container)
        {
            Container = container;
            RegionManager = regionManager;

            Container.RegisterType(typeof(ISmsView), typeof(SmsView), new ContainerControlledLifetimeManager());
            Container.RegisterType(typeof(ISmsPresenter), typeof(SmsPresenter), new ContainerControlledLifetimeManager());

            Container.RegisterType(typeof(INewSmsWizardPresenter), typeof(NewSmsWizardPresenter), new ContainerControlledLifetimeManager());
            Container.RegisterType(typeof(INewSmsWizardView), typeof(NewSmsWizardView), new ContainerControlledLifetimeManager());

        }

        public IRegionManager RegionManager { get; set; }
        public IUnityContainer Container { get; set; }

        public void Initialize()
        {
            RegionManager.Regions[RegionNames.RegionMain].Add(Container.Resolve<ISmsPresenter>().View);
        }
    }
}